package com.mz.ozy.adapter;

import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.GoodsCategoryBean;
import com.mz.ozy.bean.VoucherBean;

import java.util.List;

public class PayActivityAdapter extends BaseQuickAdapter<VoucherBean.AcListBean, BaseViewHolder> {

    private int selectPosition = -1;
    private int id;

    public PayActivityAdapter(@Nullable List<VoucherBean.AcListBean> data, int id) {
        super(R.layout.item_pay_activity, data);
        this.id = id;
        if (data != null && data.size() > 0) {
            for (int i = 0; i < data.size(); i++) {
                VoucherBean.AcListBean cateListBean = data.get(i);
                if (this.id == cateListBean.getId()) {
                    selectPosition = i;
                }
            }
        }
    }

    public void setSelectPosition(int selectPosition) {
        this.selectPosition = selectPosition;
    }

    @Override
    protected void convert(BaseViewHolder helper, VoucherBean.AcListBean item) {
        helper.setText(R.id.brandNameTv, item.getName());
        if (selectPosition == helper.getAdapterPosition()) {
            helper.setImageResource(R.id.iv_sort_select, R.mipmap.cb_red_select);
        } else {
            helper.setImageResource(R.id.iv_sort_select, R.mipmap.cb_red_normal);
        }
    }
}
